/*
 * Network.java
 * 
 *  author: Daniel Rudigier
 *    date: 10.12.2008
 * 
 * 
 */
package at.syncme.framework;


/**
 * this is the network super-class that defines the protocol for an algorithm
 * 
 * @author Daniel Rudigier
 */
public abstract class Network {
    protected Algorithm algorithm;

    /**
     * register the algorithm for the network, to inform about incoming network
     * event.
     * 
     * @param a
     */
    public void setAlgorithm(final Algorithm a) {
        this.algorithm = a;
    }

    /**
     * @return algorithm
     */
    public Algorithm getAlgorithm() {
        return algorithm;
    }

    /**
     * helper class for algorithm. send an event to a specific outgoing node
     * represented by an established connection.
     * 
     * @param nodeId
     * @param e
     */
    public abstract void sendToNode(final short nodeId, final Event e);

    /**
     * helper class for algorithm. send to all established connections, except
     * to myself.
     * 
     * @param e
     */
    public abstract void sendToAllNodes(final Event e);

}
